package org.getOffer.offer53_2;

/**
 * @Author: wjy
 * @Date: 2021/9/23 15:24
 */
public class Solution {

    public static void main(String[] args) {

        int[] nums = {0,1};
        System.out.println(missingNumber(nums));
    }

    public static int missingNumber(int[] nums) {

        int left = 0, right = nums.length-1;

        while (left <= right) {

            int mid = (left + right)/2;

            if (nums[mid] == mid) {
                left = mid+1;
            }
            if (nums[mid] > mid) {
                right = mid-1;
            }
        }

        if (right < left) {
            return left;
        }
        return 0;
    }

}
